#include "FrontendState.h"

FrontendState::FrontendState(GameContext& gc)
	:GameState(gc)
{
}

FrontendState::~FrontendState(void)
{
}

void FrontendState::Load()
{
	mFont.Load(20);
	mCursor.Load("sword.png");

	mStartButton1.Load("button_on.png", "button_off.png");
	mStartButton1.SetPosition(SVector2(200.0f, 500.0f));
	mStartButton1.SetText("Level 1", 255, 255, 255);

	mStartButton2.Load("button_on.png", "button_off.png");
	mStartButton2.SetPosition(SVector2(200.0f, 550.0f));
	mStartButton2.SetText("Level 2", 255, 255, 255);

	mQuitButton.Load("button_on.png", "button_off.png");
	mQuitButton.SetPosition(SVector2(200.0f, 600.0f));
	mQuitButton.SetText("Quit", 255, 255, 255);
}

void FrontendState::Unload()
{
	mFont.Unload();
	mCursor.Unload();
	mStartButton1.Unload();
	mStartButton2.Unload();
	mQuitButton.Unload();
}

NextState FrontendState::Update(float deltaTime)
{
	mCursor.Update(deltaTime);
	mStartButton1.Update(deltaTime);
	mStartButton2.Update(deltaTime);
	mQuitButton.Update(deltaTime);

	NextState nextState = None;

	if(mStartButton1.IsPressed())
	{
		mGameContext.SetLevel(1);
		nextState = Gameplay;
	}
	else if(mStartButton2.IsPressed())
	{
		mGameContext.SetLevel(2);
		nextState = Gameplay;
	}
	else if(mQuitButton.IsPressed())
	{
		nextState = Quit;
	}
	return nextState;
}

void FrontendState::Render()
{
	mFont.Print("A Link to Pikachu's Past", 100, 100);
	mStartButton1.Render();
	mStartButton2.Render();
	mQuitButton.Render();
	mCursor.Render();
}